<?php


namespace app\index\model;


use think\Model;

class Experience extends Model
{
    /**
     * 个人页，获取用户实习公司以及项目经历
     * ywh开发
     *
     * @param $human
     * @return Experience[]|\think\Collection
     */
    public function getTempAttr($human){
        return $this->alias('temp')
            ->join(['user' => 'user'],'user.user_id = temp.user_id')
            ->join(['project' => 'project'],'project.user_id = user.user_id')
            ->field(['temp.company_name','temp.com_class','temp.department','temp.job','temp.injob_time','temp.outjob_time','(temp.outjob_time - temp.injob_time) / 31536000 as year'])
            ->field(['project.project','project.pro_name','project.mypro'] )
            ->where('user.user_id' , '=' , $human)
            ->select();
    }

    /**
     * 编辑用户实习经历
     * ywh开发
     * @param $human
     * @param $data
     * @return Experience
     */
    public function upTemp($human,$data){
        return $this->where('user_id','=',$human)->update($data);
    }
}